﻿using System.Collections.Generic;

namespace Minecraft_2D.Blocks
{
    class BlocSet
    {
        #region Attributs
        private static BlocSet _singleton;
        private static int _staticId;
        private int _percent;
        private Dictionary<int, Bloc> _set;
        #endregion

        #region Constructeur
        public BlocSet()
        {
            _set = new Dictionary<int, Bloc>();
            //_set.Add(id, new Bloc(appear));
            _set.Add(_staticId++, new Bloc("", null, false, 20));
            _set.Add(_staticId++, new Stone(8));
            _set.Add(_staticId++, new Grass(30));
            _set.Add(_staticId++, new Wood(6));
            _set.Add(_staticId++, new Plank(0));
            _set.Add(_staticId++, new BedRock(10));
            _set.Add(_staticId++, new Dirt(0));
            _set.Add(_staticId++, new Leaves(0));

            foreach (Bloc b in _set.Values)
            {
                _percent += b.Percent;
            }
        }
        #endregion

        #region Proprietes
        public Bloc this[int i]
        {
            get { return _set[i]; }
        }

        public Bloc this[TypeBloc i]
        {
            get { return _set[(int)i]; }
        }

        public int Count
        {
            get { return _staticId; }
        }

        public int Percent
        {
            get { return _percent; }
        }
        #endregion

        #region Methodes
        public static BlocSet GetSingleton()
        {
            if (_singleton == null)
                _singleton = new BlocSet();
            return _singleton;
        }
        #endregion
    }
}
